﻿<Window
    x:Class="ResxUnusedFinder.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:command="http://www.galasoft.ch/mvvmlight"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:prop="clr-namespace:ResxUnusedFinder.Properties"
    Title="RESX Unused Finder"
    Width="650"
    Height="450"
    MinWidth="600"
    MinHeight="300"
    Closing="Window_Closing">
    <Window.Resources>
        <Style x:Key="FieldLabel" TargetType="TextBlock">
            <Setter Property="Margin" Value="4,0,4,0" />
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>
        <Style x:Key="SectionHeader" TargetType="TextBlock">
            <Setter Property="Margin" Value="0,0,0,0" />
            <Setter Property="FontWeight" Value="Bold" />
        </Style>
        <Style x:Key="BrowseButton" TargetType="Button">
            <Setter Property="Margin" Value="6,0,0,0" />
            <Setter Property="Padding" Value="6,1" />
        </Style>
        <Style x:Key="ActionButton" TargetType="Button">
            <Setter Property="Margin" Value="6,0,0,0" />
            <Setter Property="Padding" Value="6,1" />
        </Style>
        <Style x:Key="Field" TargetType="TextBox">
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>
        <Style x:Key="LongToolTip" TargetType="TextBlock">
            <Setter Property="Width" Value="300" />
            <Setter Property="TextWrapping" Value="Wrap" />
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Orientation="Vertical">
            <Border Background="WhiteSmoke" Padding="6">
                <StackPanel Orientation="Vertical">
                    <Grid ToolTipService.ShowDuration="20000">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.ToolTip>
                            <TextBlock Style="{StaticResource LongToolTip}" Text="The root project folder that contains all possible string references." />
                        </Grid.ToolTip>
                        <TextBlock
                            Margin="0,0,6,0"
                            Style="{StaticResource FieldLabel}"
                            Text="Project folder:" />

                        <TextBox Grid.Column="1" Text="{Binding ProjectFolder}" />

                        <Button
                            Grid.Column="2"
                            Command="{Binding BrowseFolderCommand}"
                            Content="Browse..."
                            Style="{StaticResource BrowseButton}" />
                    </Grid>

                    <TextBlock
                        Margin="0,8,0,0"
                        Style="{StaticResource SectionHeader}"
                        Text="Definitions" />

                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Style="{StaticResource FieldLabel}" Text="Resource file:" />

                        <TextBox Grid.Column="1" Text="{Binding ResourceFile}" />

                        <Button
                            Grid.Column="2"
                            Command="{Binding BrowseResourceFileCommand}"
                            Content="Browse..."
                            Style="{StaticResource BrowseButton}" />
                    </Grid>

                    <TextBlock
                        Margin="0,8,0,0"
                        Style="{StaticResource SectionHeader}"
                        Text="References" />
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="24" />
                            <RowDefinition Height="24" />
                            <RowDefinition Height="24" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <TextBlock
                            Style="{StaticResource FieldLabel}"
                            Text="Extensions:"
                            ToolTipService.ShowDuration="20000">
                            <TextBlock.ToolTip>
                                <TextBlock Style="{StaticResource LongToolTip}" Text="{x:Static prop:Resources.ExtensionsToolTip}" />
                            </TextBlock.ToolTip>
                        </TextBlock>
                        <TextBox
                            Grid.Row="0"
                            Grid.Column="1"
                            Style="{StaticResource Field}"
                            Text="{Binding Extensions}"
                            ToolTipService.ShowDuration="20000">
                            <TextBox.ToolTip>
                                <TextBlock Style="{StaticResource LongToolTip}" Text="{x:Static prop:Resources.ExtensionsToolTip}" />
                            </TextBox.ToolTip>
                        </TextBox>

                        <TextBlock
                            Grid.Row="1"
                            Grid.Column="0"
                            Style="{StaticResource FieldLabel}"
                            Text="Reference Formats:"
                            ToolTipService.ShowDuration="20000">
                            <TextBlock.ToolTip>
                                <TextBlock Style="{StaticResource LongToolTip}" Text="{x:Static prop:Resources.ReferenceFormatsToolTip}" />
                            </TextBlock.ToolTip>
                        </TextBlock>
                        <TextBox
                            Grid.Row="1"
                            Grid.Column="1"
                            Style="{StaticResource Field}"
                            Text="{Binding ReferenceFormats}"
                            ToolTipService.ShowDuration="20000">
                            <TextBox.ToolTip>
                                <TextBlock Style="{StaticResource LongToolTip}" Text="{x:Static prop:Resources.ReferenceFormatsToolTip}" />
                            </TextBox.ToolTip>
                        </TextBox>

                        <TextBlock
                            Grid.Row="2"
                            Grid.Column="0"
                            Style="{StaticResource FieldLabel}"
                            Text="Excluded Key Prefixes:"
                            ToolTipService.ShowDuration="20000">
                            <TextBlock.ToolTip>
                                <TextBlock Style="{StaticResource LongToolTip}" Text="{x:Static prop:Resources.ExcludedPrefixesToolTip}" />
                            </TextBlock.ToolTip>
                        </TextBlock>
                        <TextBox
                            Grid.Row="2"
                            Grid.Column="1"
                            Style="{StaticResource Field}"
                            Text="{Binding ExcludePrefixes}"
                            ToolTipService.ShowDuration="20000">
                            <TextBox.ToolTip>
                                <TextBlock Style="{StaticResource LongToolTip}" Text="{x:Static prop:Resources.ExcludedPrefixesToolTip}" />
                            </TextBox.ToolTip>
                        </TextBox>
                    </Grid>

                    <Grid Margin="0,8,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <StackPanel Grid.Column="0" Orientation="Horizontal">
                            <TextBlock Style="{StaticResource SectionHeader}" Text="Unused Resources" />
                            <Button Command="{Binding RefreshCommand}" Style="{StaticResource ActionButton}">
                                <StackPanel Orientation="Horizontal">
                                    <Image
                                        Width="16"
                                        Height="16"
                                        Source="/Icons/refresh.png" />
                                    <TextBlock Margin="2,0,0,0" Text="Refresh" />
                                </StackPanel>
                            </Button>
                            <Button Command="{Binding CopyCommand}" Style="{StaticResource ActionButton}" UseLayoutRounding="True">
                                <StackPanel Orientation="Horizontal">
                                    <Image
                                        Width="16"
                                        Height="16"
                                        Source="/Icons/copy.png" />
                                    <TextBlock Margin="2,0,0,0" Text="Copy" />
                                </StackPanel>
                            </Button>
                            <Button Command="{Binding DeleteAllCommand}" Style="{StaticResource ActionButton}">
                                <StackPanel Orientation="Horizontal">
                                    <Image
                                        Width="16"
                                        Height="16"
                                        Source="/Icons/delete.png" />
                                    <TextBlock Margin="2,0,0,0" Text="Delete All" />
                                </StackPanel>
                            </Button>
                        </StackPanel>
                        <StackPanel
                            Grid.Column="1"
                            Orientation="Horizontal"
                            Visibility="{Binding ItemsSelected,
                                                         Converter={StaticResource VisibilityConverter}}">
                            <Button
                                Command="{Binding ExcludeSelectedCommand}"
                                Content="Exclude Selected"
                                Style="{StaticResource ActionButton}" />
                            <Button Command="{Binding DeleteSelectedCommand}" Style="{StaticResource ActionButton}">
                                <StackPanel Orientation="Horizontal">
                                    <Image
                                        Width="16"
                                        Height="16"
                                        Source="/Icons/delete.png" />
                                    <TextBlock Margin="2,0,0,0" Text="Delete Selected" />
                                </StackPanel>
                            </Button>
                        </StackPanel>
                    </Grid>

                </StackPanel>
            </Border>
        </StackPanel>
        <ListView Grid.Row="1" ItemsSource="{Binding UnusedResources}">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <command:EventToCommand Command="{Binding OnSelectionChangedCommand}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <ListView.View>
                <GridView>
                    <GridView.Columns>
                        <GridViewColumn
                            x:Name="keyColumn"
                            Width="200"
                            DisplayMemberBinding="{Binding Key}"
                            Header="Key" />
                        <GridViewColumn
                            x:Name="valueColumn"
                            Width="350"
                            Header="Value">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Value}" ToolTipService.ShowDuration="20000">
                                        <TextBlock.ToolTip>
                                            <TextBlock Style="{StaticResource LongToolTip}" Text="{Binding Value}" />
                                        </TextBlock.ToolTip>
                                    </TextBlock>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView.Columns>
                </GridView>
            </ListView.View>
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
        <TextBlock
            Grid.Row="2"
            Margin="3"
            Background="WhiteSmoke"
            Text="{Binding Status}" />
    </Grid>
</Window>
